using System;
using System.Collections.Generic;
using System.ComponentModel;

using Sinacor.Servico.Bovespa.Ordens.BusinessEntity;
using Sinacor.Servico.Bovespa.Ordens.Service.DataContract.Response;

namespace Sinacor.Servico.Bovespa.Ordens.Service.ServiceImplementation.Translator
{
    public static class TranslateBetweenMercadoResponseAndMercado
    {
        public static DataContract.Response.MercadoResponse TranslateMercadoToMercadoResponse(BusinessEntity.Mercado from)
        {

            if (from == null) return null;

            DataContract.Response.MercadoResponse to = new DataContract.Response.MercadoResponse();
            to.Codigo = from.Codigo;
            to.Descricao = from.Descricao;
            to.TipoMercado = (DataContract.Enum.TipoMercado)from.TipoMercado;
            return to;
            
        }

        public static BusinessEntity.Mercado TranslateMercadoResponseToMercado(DataContract.Response.MercadoResponse from)
        {
            if (from == null) return null; 
            
            BusinessEntity.Mercado to = new BusinessEntity.Mercado();
            to.Codigo = from.Codigo;
            to.Descricao = from.Descricao;
            to.TipoMercado = (BusinessEntity.Enum.TipoMercado) from.TipoMercado;
            return to;

        }

        public static List<DataContract.Response.MercadoResponse> TranslateMercadoListToMercadoResponseList(List<BusinessEntity.Mercado> from)
        {

            if (from == null) return null; 

            List<DataContract.Response.MercadoResponse> to = new List<MercadoResponse>();
            foreach (BusinessEntity.Mercado fromItem in from)
            {
                to.Add(Translator.TranslateBetweenMercadoResponseAndMercado.TranslateMercadoToMercadoResponse(fromItem));
            }

            return to;

        }

        public static List<BusinessEntity.Mercado> TranslateMercadoResponseListToMercadoList(List<DataContract.Response.MercadoResponse> from)
        {

            if (from == null) return null;

            List<BusinessEntity.Mercado> to = new List<BusinessEntity.Mercado>();
            foreach (DataContract.Response.MercadoResponse fromItem in from)
            {
                to.Add(Translator.TranslateBetweenMercadoResponseAndMercado.TranslateMercadoResponseToMercado(fromItem));
            }

            return to;

        }

    }

}

